<%@include file="menu/util.jsp" %>
<%@page contentType="text/html; charset=iso-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <fmt:bundle basename="app">
        <head>

            <%@include file="menu/wizardTablessHeader.jsp" %>


            <script type="text/javascript">
                $.validator.setDefaults({
                    submitHandler: function() {
                        var name = $('#name').attr('value');
                        var description = $('#description').attr('value');
                        if($('#noteTyId').attr('value') > 0){
                            var id = $('#noteTyId').attr('value');
                            editNoteType(id,name,description);
                        }else{
                            insertNoteType(name,description);
                        }
                       
                    }
                });

                $().ready(function() {
                    // validate the comment form when it is submitted
                    $("#newNotetype").validate({
		errorLabelContainer: $(".errorDiv"),
                wrapper: "li"
	});
                    $("#noteTypeId").change(function(){
                        selectNoteType($(this).val());
                    });
                });
            </script>

            <c:set var="name" value=""/>
            <c:set var="description" value=""/>
            <c:set var="id" value=""/>

            <c:if test="${noteType != null}" >
                <c:set var="name" value="${noteType.name}"/>
                <c:set var="description" value="${noteType.description}"/>
                <c:set var="id" value="${noteType.idNoteType}"/>
            </c:if>
        </head>

        <body style="overflow:hidden;" >

            <form id="newNotetype" action="newNoteType.do">

                <%@include file="menu/wizardTablessHeader2.jsp" %>

                <table>

                    <c:if test="${notNoteTypes != null }">
                        <tr>
                            <td>
                                <fmt:message key="forms.suggestion" />
                            </td>
                            <td>
                                <select name="noteTypeId" id="noteTypeId">
                                    <option value="-1"><fmt:message key="forms.selectoption" /></option>
                                    <c:forEach items="${notNoteTypes}" var="noteType">
                                        <option value="${noteType.idNoteType}">${noteType.name}</option>
                                    </c:forEach>
                                </select>
                            </td>
                        </tr>
                    </c:if>

                    <tr>
                        <td>
                            <fmt:message key="forms.name" />
                        </td>
                        <td>
                            <input class="required" title="<fmt:message key="error.notes.name"/>" type="text" name="name" id="name" value="${name}" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <fmt:message key="forms.description" />
                        </td>
                        <td>
                            <input type="text" name="description" title="<fmt:message key="error.notes.description"/>" id="description" value="${description}" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                        </td>
                    </tr>
                </table>

                <input type="hidden" id="noteTyId" name="noteTyId" value="${id}" />

                <%@include file="menu/wizardTablessMidle.jsp" %>
                <%@include file="menu/wizardTablessFooter.jsp" %>
            </form>

        </body>
    </fmt:bundle>
</html>

